/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {Form,  Input ,InputNumber,Radio,Popover,Select,DatePicker,Button,Upload,Icon ,Cascader} from 'antd';
import {connect} from 'dva';
import {download} from '@/utils/utils';
import request from '@/utils/request';
import config from '@/config/config'
const FormItem = Form.Item;
const Option = Select.Option;
class EditUserArchives extends Component {
  constructor(props) {
    super(props);
    this.state = {
      fileList: [],
      concentrators:[],
      all_protocols:[]
    };
  }
  componentDidMount() {
  }
  getState=()=>{
    return this.state.fileList
  }
  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 7},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };
    const props = {
      onRemove: (file) => {
        this.setState(({ fileList }) => {
          const index = fileList.indexOf(file);
          const newFileList = fileList.slice();
          newFileList.splice(index, 1);
          return {
            fileList: newFileList,
          };
        });
      },
      beforeUpload: (file) => {
        this.setState(({ fileList }) => ({
          fileList: [file],
        }));
        return false;
      },
      fileList: this.state.fileList,
      accept:".xls,.xlsx"
    };
    const {getFieldDecorator, getFieldValue} = this.props.form;
    return (
      <div>
        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={'Excel文件'}
          >
            <div className="dropbox">
              {getFieldDecorator('file', {
                rules: [{required: true, message: 'Excel文件不能为空'}],
              })(
                <Upload.Dragger {...props}>
                  <p className="ant-upload-drag-icon">
                    <Icon type="inbox" />
                  </p>
                  <p className="ant-upload-text">点击这个区域选择Excel文件</p>
                </Upload.Dragger>
              )}
            </div>
          </FormItem>
          <FormItem
            label={'开始导入行号'}
            {...formItemLayoutWithLabel}
          >
            {getFieldDecorator('start_row', {
              initialValue: 2,
            })(
              <InputNumber min={2} style={{width:'100%'}}/>
            )}
          </FormItem>
          <FormItem
            label={<span>
              结束导入行号
              <Popover content={<div>
                不填默认文件最后一行
              </div>} title="">
                <Icon type="question-circle-o" />
                </Popover>
            </span>}
            {...formItemLayoutWithLabel}
          >
            {getFieldDecorator('end_row', {
            })(
              <InputNumber style={{width:'100%'}}/>
            )}
          </FormItem>

        </Form>
      </div>
    );
  }
}

const EditUserArchivesFormWrap = Form.create()(EditUserArchives);
export default connect()(EditUserArchivesFormWrap);
